package com.forstudy.controller;

import com.forstudy.common.bean.AjaxResponse;
import com.forstudy.common.bean.BaseController;
import com.forstudy.service.IFileService;
import com.forstudy.util.ExcelUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: erdong
 * Date: 2020/4/15
 * Time: 16:33
 * Description: No Description
 */
@RequestMapping("/file")
@RestController
public class FileController extends BaseController {

    @Autowired
    private IFileService fileService;

    @PostMapping("/upload")
    @ApiOperation(value = "上传EXCEL文件")
    public AjaxResponse uploadFile(HttpServletRequest request, MultipartFile file) throws Exception {

        AjaxResponse response = new AjaxResponse();
        response.setData(fileService.upload(request, file));
        return response;
    }

    @PostMapping("/import/order")
    public AjaxResponse import_order(MultipartFile excel) {

        AjaxResponse response = new AjaxResponse();

        return response;
    }
}
